package org.grew.openEntity.repository;

import org.grew.openEntity.po.logic.ProjectObj;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @program: open_entity
 * @author: todd
 * @create: 2019-01-05 21:32
 * @description: 项目对象 数据仓库
 */
@Repository
public interface ProjectRepository extends JpaRepository<ProjectObj,Long> {


    @Query(value = "from ProjectObj p where p.projectName like %:projectName%")
    List<ProjectObj> findProjectObjByProjectName(@Param("projectName") String projectName);


    @Query(value = "from ProjectObj p where p.projectName = :projectName")
    Optional<ProjectObj> checkProjectName(@Param("projectName") String projectName);

    @Query(value = "select p from ProjectObj p")
    Page<ProjectObj> getProjectObjsByPage(Pageable pageable);

}
